package com.design.paystyle.controller;

import com.design.paystyle.annotation.SysLog;
import com.design.paystyle.service.PayService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 支付接口
 *
 * @author by liuxin
 * @version 0.1
 */
@Slf4j
@RestController
@RequestMapping("/api/w/")
public class PayController {

    @Resource
    private PayService payService;

    /**
     * 支付
     *
     * @param payCode 支付方式
     * @return 支付结果
     */
    @RequestMapping(value = {"/pay"}, method = RequestMethod.GET, produces = {"application/json; " +
            "charset=UTF-8"})
    public String pay(String payCode) {
        log.info("调用支付接口");
        return payService.toPay(payCode);
    }

    /**
     * 无参接口
     *
     * @return 字符串
     */
    @RequestMapping(value = {"/hello"}, method = RequestMethod.POST, produces = {"application/json; charset=UTF-8"})
    public String sayHello() {
        log.info("无参接口");
        return "hello world";
    }

    /**
     * 测试日志注解
     *
     * @return 字符串
     */
    @RequestMapping(value = {"/log"}, method = RequestMethod.POST, produces = {"application/json; charset=UTF-8"})
    @SysLog("测试日志注解")
    public String toLog() {
        log.info("测试日志注解");
        return "测试日志注解";
    }
}
